﻿
Imports System.Security
Imports System.Security.Principal.WindowsIdentity

Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Xml



Public Class Startup



    Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        Me.TransparencyKey = Me.BackColor
        ' Add any initialization after the InitializeComponent() call.

    End Sub


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs)

        Me.Close()

    End Sub

    Private Sub Startup_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim s() As String

        'Get build version
        Try
            Dim m_xmld = New XmlDocument()
            m_xmld.Load(Application.ExecutablePath & ".manifest")
            Info.Text = "JLD004 Version: " & m_xmld.ChildNodes.Item(1).ChildNodes.Item(0).Attributes.GetNamedItem("version").Value
        Catch ex As Exception

        End Try


        s = Split(GetCurrent.Name, "\")
        Me.LabelControl1.Text = s(1).ToUpper
        Me.LabelControl4.Text = s(0).ToUpper
        Me.LabelControl5.Text = "Checking your acount ...."





        Me.SimpleButton1.Visible = False
        Application.DoEvents()

        CheckUser(s(1).ToUpper)

    End Sub

    Private Sub CheckUser(ByVal User As String)
        Dim M3Con As New System.Data.OleDb.OleDbConnection(My.Settings.M3ConnectUser)
        Dim M3Cmd As New System.Data.OleDb.OleDbCommand
        Dim M3Reader As OleDb.OleDbDataReader = Nothing

        'Open connection to M3
        M3Cmd.Connection = M3Con

        M3Con.Open()

        'Get all opened records
        M3Cmd.CommandText = "SELECT JLENV FROM F4001 WHERE JLUSER = '" & User & "'"
        M3Reader = M3Cmd.ExecuteReader

        If M3Reader.Read Then
            Me.LabelControl5.Text = "Your acount is enabled ....."
            Me.Timer1.Enabled = True
        Else
            Me.LabelControl5.Text = "Your acount is not set please contact your administrator ....."
            Me.SimpleButton1.Visible = True
        End If

        M3Con.Close()
    End Sub

    Private Sub SimpleButton1_Click(sender As System.Object, e As System.EventArgs) Handles SimpleButton1.Click
        Application.Exit()

    End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        Me.Close()
    End Sub

  
End Class